package cn.bonoon.kernel.descriptors.impl;

import javassist.CannotCompileException;
import javassist.ClassClassPath;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.NotFoundException;

public abstract class AbstractBytecode {
	protected final static ClassPool pool = ClassPool.getDefault();
	private static long count = 0;
	static{
		pool.insertClassPath(new ClassClassPath(AbstractBytecode.class));
	}
	protected static final CtClass __MAKE(String pre, Object name, Class<?> sc) 
			throws NotFoundException, CannotCompileException{
		CtClass cc = pool.makeClass(pre + '_' + name + "_impl_" + (count++));
		cc.setSuperclass(pool.get(sc.getName()));
		return cc;
	}
	
	protected static final CtClass __GET(String name) throws NotFoundException{
		return pool.get(name);
	}
	
	protected static final CtClass __GET(Class<?> cls) throws NotFoundException{
		return pool.get(cls.getName());
	}
}
